package zt.song.boot.interceptor;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * @Author 宋伟宁
 * @Date 2023/11/8
 * @Version 1.0
 **/
public class MyInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("11111111111111111");

        HttpSession session = request.getSession();
        String uri = request.getRequestURI();
        if(uri.endsWith("list") || session.getAttribute("admin")!=null){
            return true;
        }
        return false;
    }
}
